home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / btncreat / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  15.9 KB  |  522 lines

  1. VERSION 2.00
  2. Begin Form names 
  3.    BackColor       =   &H00808080&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Customer Address"
  6.    ClientHeight    =   5280
  7.    ClientLeft      =   615
  8.    ClientTop       =   1605
  9.    ClientWidth     =   8295
  10.    ForeColor       =   &H00808080&
  11.    Height          =   5970
  12.    Left            =   555
  13.    LinkMode        =   1  'Source
  14.    LinkTopic       =   "Form1"
  15.    ScaleHeight     =   5280
  16.    ScaleMode       =   0  'User
  17.    ScaleWidth      =   8400.607
  18.    Top             =   975
  19.    Width           =   8415
  20.    Begin Frame Frame1 
  21.       BackColor       =   &H00C0C0C0&
  22.       Caption         =   "Customer/Address/Record"
  23.       ForeColor       =   &H00000000&
  24.       Height          =   4212
  25.       Left            =   120
  26.       TabIndex        =   11
  27.       Top             =   600
  28.       Width           =   8052
  29.       Begin TextBox Text1 
  30.          Height          =   372
  31.          Index           =   10
  32.          Left            =   1680
  33.          TabIndex        =   10
  34.          Text            =   " "
  35.          Top             =   3480
  36.          Width           =   2172
  37.       End
  38.       Begin TextBox Text1 
  39.          Height          =   372
  40.          Index           =   9
  41.          Left            =   5040
  42.          TabIndex        =   9
  43.          Text            =   " "
  44.          Top             =   2880
  45.          Width           =   1572
  46.       End
  47.       Begin TextBox Text1 
  48.          Height          =   372
  49.          Index           =   8
  50.          Left            =   4080
  51.          TabIndex        =   8
  52.          Text            =   " "
  53.          Top             =   2880
  54.          Width           =   372
  55.       End
  56.       Begin TextBox Text1 
  57.          Height          =   372
  58.          Index           =   7
  59.          Left            =   1680
  60.          TabIndex        =   7
  61.          Text            =   " "
  62.          Top             =   2880
  63.          Width           =   1692
  64.       End
  65.       Begin TextBox Text1 
  66.          Height          =   372
  67.          Index           =   6
  68.          Left            =   1680
  69.          TabIndex        =   6
  70.          Text            =   " "
  71.          Top             =   2400
  72.          Width           =   4572
  73.       End
  74.       Begin TextBox Text1 
  75.          Height          =   372
  76.          Index           =   5
  77.          Left            =   1680
  78.          TabIndex        =   5
  79.          Text            =   " "
  80.          Top             =   1920
  81.          Width           =   4572
  82.       End
  83.       Begin TextBox Text1 
  84.          Height          =   372
  85.          Index           =   4
  86.          Left            =   6600
  87.          TabIndex        =   4
  88.          Text            =   " "
  89.          Top             =   1440
  90.          Width           =   372
  91.       End
  92.       Begin TextBox Text1 
  93.          Height          =   372
  94.          Index           =   3
  95.          Left            =   3840
  96.          TabIndex        =   3
  97.          Text            =   " "
  98.          Top             =   1440
  99.          Width           =   1692
  100.       End
  101.       Begin TextBox Text1 
  102.          Height          =   372
  103.          Index           =   2
  104.          Left            =   1680
  105.          TabIndex        =   2
  106.          Text            =   " "
  107.          Top             =   1440
  108.          Width           =   1332
  109.       End
  110.       Begin TextBox Text1 
  111.          Height          =   372
  112.          Index           =   1
  113.          Left            =   1680
  114.          TabIndex        =   1
  115.          Text            =   " "
  116.          Top             =   720
  117.          Width           =   612
  118.       End
  119.       Begin Label Label10 
  120.          BackColor       =   &H00C0C0C0&
  121.          Caption         =   "Telephone"
  122.          Height          =   372
  123.          Left            =   600
  124.          TabIndex        =   13
  125.          Top             =   3480
  126.          Width           =   972
  127.       End
  128.       Begin Label Label9 
  129.          BackColor       =   &H00C0C0C0&
  130.          Caption         =   "Zip"
  131.          Height          =   372
  132.          Left            =   4560
  133.          TabIndex        =   14
  134.          Top             =   2880
  135.          Width           =   372
  136.       End
  137.       Begin Label Label8 
  138.          BackColor       =   &H00C0C0C0&
  139.          Caption         =   "State"
  140.          Height          =   372
  141.          Left            =   3480
  142.          TabIndex        =   0
  143.          Top             =   2880
  144.          Width           =   492
  145.       End
  146.       Begin Label Label7 
  147.          BackColor       =   &H00C0C0C0&
  148.          Caption         =   "City"
  149.          Height          =   372
  150.          Left            =   600
  151.          TabIndex        =   17
  152.          Top             =   2880
  153.          Width           =   852
  154.       End
  155.       Begin Label Label5 
  156.          BackColor       =   &H00C0C0C0&
  157.          Caption         =   "Address"
  158.          Height          =   372
  159.          Left            =   600
  160.          TabIndex        =   18
  161.          Top             =   2400
  162.          Width           =   852
  163.       End
  164.       Begin Label Label4 
  165.          BackColor       =   &H00C0C0C0&
  166.          Caption         =   "Company"
  167.          Height          =   372
  168.          Left            =   600
  169.          TabIndex        =   12
  170.          Top             =   1920
  171.          Width           =   852
  172.       End
  173.       Begin Label Label2 
  174.          BackColor       =   &H00C0C0C0&
  175.          Caption         =   "Initial"
  176.          Height          =   372
  177.          Left            =   6000
  178.          TabIndex        =   15
  179.          Top             =   1440
  180.          Width           =   492
  181.       End
  182.       Begin Label Label3 
  183.          BackColor       =   &H00C0C0C0&
  184.          Caption         =   "Last name"
  185.          Height          =   372
  186.          Left            =   3240
  187.          TabIndex        =   16
  188.          Top             =   1440
  189.          Width           =   492
  190.       End
  191.       Begin Label Label1 
  192.          BackColor       =   &H00C0C0C0&
  193.          Caption         =   "First Name"
  194.          ForeColor       =   &H00000000&
  195.          Height          =   372
  196.          Left            =   600
  197.          TabIndex        =   19
  198.          Top             =   1440
  199.          Width           =   852
  200.       End
  201.       Begin Label Label6 
  202.          BackColor       =   &H00C0C0C0&
  203.          Caption         =   "Id Number"
  204.          ForeColor       =   &H00000000&
  205.          Height          =   372
  206.          Left            =   600
  207.          TabIndex        =   20
  208.          Top             =   720
  209.          Width           =   852
  210.       End
  211.    End
  212.    Begin PictureBox Picture1 
  213.       AutoSize        =   -1  'True
  214.       BackColor       =   &H00C0C0C0&
  215.       BorderStyle     =   0  'None
  216.       ForeColor       =   &H00C0C0C0&
  217.       Height          =   480
  218.       Index           =   3
  219.       Left            =   3840
  220.       Picture         =   FORM1.FRX:0000
  221.       ScaleHeight     =   480
  222.       ScaleWidth      =   480
  223.       TabIndex        =   23
  224.       Top             =   120
  225.       Width           =   480
  226.    End
  227.    Begin PictureBox NextRec 
  228.       AutoSize        =   -1  'True
  229.       BackColor       =   &H00FFFFFF&
  230.       BorderStyle     =   0  'None
  231.       Height          =   480
  232.       Index           =   2
  233.       Left            =   2040
  234.       Picture         =   FORM1.FRX:0302
  235.       ScaleHeight     =   480
  236.       ScaleWidth      =   480
  237.       TabIndex        =   22
  238.       Top             =   120
  239.       Width           =   480
  240.    End
  241.    Begin PictureBox Previous 
  242.       AutoSize        =   -1  'True
  243.       BackColor       =   &H00FFFFFF&
  244.       BorderStyle     =   0  'None
  245.       Height          =   480
  246.       Index           =   1
  247.       Left            =   720
  248.       Picture         =   FORM1.FRX:0604
  249.       ScaleHeight     =   480
  250.       ScaleWidth      =   480
  251.       TabIndex        =   21
  252.       Top             =   120
  253.       Width           =   480
  254.    End
  255.    Begin Menu AddRecord 
  256.       Caption         =   "Add"
  257.    End
  258.    Begin Menu UpdateRecord 
  259.       Caption         =   "Update"
  260.    End
  261.    Begin Menu DeleteRecord 
  262.       Caption         =   "Delete"
  263.    End
  264.    Begin Menu QueryClearTextBoxes 
  265.       Caption         =   "Query"
  266.    End
  267.    Begin Menu SearchRecord 
  268.       Caption         =   "Search"
  269.    End
  270.    Begin Menu FirstRecord 
  271.       Caption         =   "First"
  272.    End
  273.    Begin Menu LastRecord 
  274.       Caption         =   "Last"
  275.    End
  276.    Begin Menu NextRecord 
  277.       Caption         =   "Next"
  278.    End
  279.    Begin Menu PreviousRecord 
  280.       Caption         =   "Previous"
  281.    End
  282.    Begin Menu ListRecords 
  283.       Caption         =   "List"
  284.    End
  285. Sub AddRecord_Click ()
  286.   Call LoadDataBuf
  287.   BufLen% = Len(DataBuf)
  288.   KeyBuflen% = Len(KeyBuf)
  289.   status% = btrcall(binsert, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  290.  If status% <> 0 Then
  291.    Call Message(Str$(status%))
  292.    Exit Sub
  293.  End If
  294.   Call ClearFormText
  295. End Sub
  296. Function bcreate (filename$)
  297.   FileBuf.RecLen = Len(DataBuf)
  298.   FileBuf.PageSize = 1024
  299.   FileBuf.IndxCnt = 7
  300.   FileBuf.FileFlags = 0
  301. Rem ACCOUNT NUMBER
  302.   FileBuf.KeyPosition0 = 1
  303.   FileBuf.KeyLength0 = 10
  304.   FileBuf.KeyFlags0 = exttype% + modifiable%
  305.   FileBuf.KeyType0 = bstring%
  306. Rem LAST NAME
  307.   FileBuf.KeyPosition1 = 31
  308.   FileBuf.KeyLength1 = 20
  309.   FileBuf.KeyFlags1 = exttype% + modifiable% + dup%
  310.   FileBuf.KeyType1 = bstring%
  311. Rem Company Name
  312.     FileBuf.KeyPosition2 = 52
  313.     FileBuf.KeyLength2 = 30
  314.     FileBuf.KeyFlags2 = exttype% + modifiable% + dup%
  315.     FileBuf.KeyType2 = bstring%
  316. Rem Company City
  317.     FileBuf.KeyPosition3 = 112
  318.     FileBuf.KeyLength3 = 20
  319.     FileBuf.KeyFlags3 = exttype% + modifiable% + dup%
  320.     FileBuf.KeyType3 = bstring%
  321. Rem Company State
  322.     FileBuf.KeyPosition4 = 132
  323.     FileBuf.KeyLength4 = 2
  324.     FileBuf.KeyFlags4 = exttype% + modifiable% + dup%
  325.     FileBuf.KeyType4 = bstring%
  326. Rem Company Zip
  327.     FileBuf.KeyPosition5 = 134
  328.     FileBuf.KeyLength5 = 12
  329.     FileBuf.KeyFlags5 = exttype% + modifiable% + dup%
  330.     FileBuf.KeyType5 = bstring%
  331. Rem Company Telephone
  332.     FileBuf.KeyPosition6 = 144
  333.     FileBuf.KeyLength6 = 12
  334.     FileBuf.KeyFlags6 = exttype% + modifiable% + dup%
  335.     FileBuf.KeyType6 = bstring%
  336.   BufLen% = Len(FileBuf)
  337.   KeyBuf.filename = "names.btr"
  338.   KeyBuflen = Len(KeyBuffer)
  339.   BufLen% = Len(FileBuf)
  340.   KeyNum = 0
  341.   BtreiveError.BtreiveStatusError.Text = "Creating file" + Str$(KeyBuflen) + Str$(BufLen%)
  342.   status% = btrcall(bcreatenew, PositionBlock, FileBuf, BufLen%, KeyBuf, KeyBuflen, KeyNum)
  343.   If status% <> 0 Then
  344.    Call Message(Str$(status%))
  345.     Unload names
  346.     Load names
  347.   End If
  348. End Function
  349. Sub ClearFormText ()
  350. For X = 1 To SubFields
  351.     names.Text1(X).Text = ""
  352. Next X
  353. End Sub
  354. Sub ClearTextBoxes_Click ()
  355.     Call ClearFormText
  356. End Sub
  357. Sub DeleteRecord_Click ()
  358.   BufLen% = Len(DataBuf)
  359.   KeyBuflen% = Len(KeyBuf)
  360.   status% = btrcall(bdelete, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  361.  If status% <> 0 Then
  362.    Call Message("Btreive Status%=" + Str$(status%))
  363.  Else
  364.     Call Message("Record Removed")
  365.    Exit Sub
  366.  End If
  367.    Call ClearFormText
  368. End Sub
  369. Sub FirstRecord_Click ()
  370.   BufLen% = Len(DataBuf)
  371.   KeyBuflen% = Len(KeyBuf)
  372.   status% = btrcall(bfirst, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  373.  If status% <> 0 Then
  374.    Call Message(Str$(status%))
  375.    Exit Sub
  376.  End If
  377.    Call LoadFormText
  378. End Sub
  379. Sub Form_Load ()
  380. init = "/p:4096 /m:38 /u:2"
  381. X = wbtrvinit(init)
  382. KeyBuf.filename = "names.btr"
  383. KeyBuflen = Len(KeyBuffer)
  384. BufLen% = Len(DataBuf)
  385. KeyNum = 0
  386. status% = btrcall(bopen, PositionBlock, DataBuff, BufLen%, KeyBuf, KeyBuflen, KeyNum)
  387.  If status% <> 0 Then
  388.    Call Message(Str$(status%))
  389.     If status% = 12 Then
  390.         status% = bcreate(null$)
  391.         For X = 1 To 100000: Y! = Sin(X): Next X
  392.     Call Message("Creating btrieve file")
  393.     End If
  394.    End If
  395. End Sub
  396. Sub Form_Unload (Cancel As Integer)
  397.   BufLen% = Len(DataBuf)
  398.   KeyBuflen% = Len(KeyBuf)
  399.   status% = btrcall(bclose, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  400.  If status% <> 0 Then
  401.    Call Message("Btreive Close Status%" + Str$(status%))
  402.  End If
  403. End Sub
  404. Sub LastRecord_Click ()
  405.   BufLen% = Len(DataBuf)
  406.   KeyBuflen% = Len(KeyBuf)
  407.   status% = btrcall(blast, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  408.  If status% <> 0 Then
  409.    Call Message(Str$(status%))
  410.    Exit Sub
  411.  End If
  412.    Call LoadFormText
  413. End Sub
  414. Sub ListRecords_Click ()
  415.     'put your print routines here
  416. End Sub
  417. Sub LoadDataBuf ()
  418.     DataBuf.CustomerIDNumber$ = names.Text1(1).Text
  419.     DataBuf.FirstName = names.Text1(2).Text
  420.     DataBuf.Lastname = names.Text1(3).Text
  421.     DataBuf.initial = names.Text1(4).Text
  422.     DataBuf.company = names.Text1(5).Text
  423.     DataBuf.address = names.Text1(6).Text
  424.     DataBuf.city = names.Text1(7).Text
  425.     DataBuf.state = names.Text1(8).Text
  426.     DataBuf.zip = names.Text1(9).Text
  427.     DataBuf.telephone = names.Text1(10).Text
  428. End Sub
  429. Sub LoadFormText ()
  430.     names.Text1(1).Text = DataBuf.CustomerIDNumber
  431.     names.Text1(2).Text = DataBuf.FirstName
  432.     names.Text1(3).Text = DataBuf.Lastname
  433.     names.Text1(4).Text = DataBuf.initial
  434.     names.Text1(5).Text = DataBuf.company
  435.     names.Text1(6).Text = DataBuf.address
  436.     names.Text1(7).Text = DataBuf.city
  437.     names.Text1(8).Text = DataBuf.state
  438.     names.Text1(9).Text = DataBuf.zip
  439.     names.Text1(10).Text = DataBuf.telephone
  440. End Sub
  441. Sub Message (TextString$)
  442.     BtreiveError.Show 0
  443.     BtreiveError.BtreiveStatusError.Text = TextString$
  444.     For X = 1 To 100000: Y! = Sin(X): Next X
  445.     BtreiveError.Hide
  446. End Sub
  447. Sub NextRec_Click (Index As Integer)
  448.   BufLen% = Len(DataBuf)
  449.   KeyBuflen% = Len(KeyBuf)
  450.   status% = btrcall(bgetnext, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  451.  If status% <> 0 Then
  452.    Call Message(Str$(status%))
  453.    Exit Sub
  454.  End If
  455.    Call LoadFormText
  456. End Sub
  457. Sub NextRecord_Click ()
  458.   BufLen% = Len(DataBuf)
  459.   KeyBuflen% = Len(KeyBuf)
  460.   status% = btrcall(bgetnext, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  461.  If status% <> 0 Then
  462.    Call Message(Str$(status%))
  463.    Exit Sub
  464.  End If
  465.    Call LoadFormText
  466. End Sub
  467. Sub Picture1_Click (Index As Integer)
  468.   BufLen% = Len(DataBuf)
  469.   KeyBuflen% = Len(KeyBuf)
  470.   status% = btrcall(bgetnext, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  471.  If status% <> 0 Then
  472.    Call Message(Str$(status%))
  473.    Exit Sub
  474.  End If
  475.    Call LoadFormText
  476. End Sub
  477. Sub Previous_Click (Index As Integer)
  478.   BufLen% = Len(DataBuf)
  479.   KeyBuflen% = Len(KeyBuf)
  480.   status% = btrcall(bprevious, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  481.  If status% <> 0 Then
  482.    Call Message(Str$(status%))
  483.    Exit Sub
  484.  End If
  485.    Call LoadFormText
  486. End Sub
  487. Sub PreviousRecord_Click ()
  488.   BufLen% = Len(DataBuf)
  489.   KeyBuflen% = Len(KeyBuf)
  490.   status% = btrcall(bprevious, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  491.  If status% <> 0 Then
  492.    Call Message(Str$(status%))
  493.    Exit Sub
  494.  End If
  495.    Call LoadFormText
  496. End Sub
  497. Sub QueryClearTextBoxes_Click ()
  498.     Call ClearFormText
  499. End Sub
  500. Sub SearchRecord_Click ()
  501.   BufLen% = Len(DataBuf)
  502.   KeyBuflen% = Len(KeyBuf)
  503.   KeyBuf.filename = RTrim$(LTrim$(names.Text1(5).Text))
  504.   KeyNum% = 2
  505.   status% = btrcall(bgetgreaterorequal, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  506.  If status% <> 0 Then
  507.    Call Message(Str$(status%))
  508.    Exit Sub
  509.  End If
  510.    Call LoadFormText
  511. End Sub
  512. Sub UpdateRecord_Click ()
  513.   Call LoadDataBuf
  514.   BufLen% = Len(DataBuf)
  515.   KeyBuflen% = Len(KeyBuf)
  516.   status% = btrcall(bupdate, PositionBlock, DataBuf, BufLen%, KeyBuf, KeyBuflen%, KeyNum%)
  517.  If status% <> 0 Then
  518.    Call Message(Str$(status%))
  519.    Exit Sub
  520.  End If
  521. End Sub
  522.